package com.vitalfit.model.vo;

import lombok.Data;


@Data
public class UserAuthentication {
    private String token;
    private Integer userId;

    public UserAuthentication(String token, Integer userId) {
        this.token = token;
        this.userId = userId;
    }

    // 静态方法，从字符串解析出token和userId
    public static UserAuthentication fromString(String str) {
        String[] parts = str.split(",");
        String token = parts[0];
        Integer userId = Integer.parseInt(parts[1]);
        return new UserAuthentication(token, userId);
    }

    // 重写toString方法，将token和userId转换为字符串
    @Override
    public String toString() {
        return token + "," + userId;
    }

}

